//
//  XMGHotWBVc.m
//  weibo
//
//  Created by Apple on 16/7/4.
//  Copyright © 2016年 DP. All rights reserved.
//

#import "XMGHotWBVc.h"
#import "XMGHotWBCell.h"

 

@interface XMGHotWBVc ()

@end
static NSString *IM = @"hotwb";
@implementation XMGHotWBVc

- (void)viewDidLoad {
    [super viewDidLoad];
//    设置
     self.navigationItem.title = @"热门微博";
    
//    设置导航条左返回键
    UIButton *btn = [[UIButton alloc]init];
    [btn setImage:[UIImage imageNamed:@"navigationbar_back"] forState:UIControlStateNormal];
    [btn setImage:[UIImage imageNamed:@"navigationbar_back_highlighted"] forState:UIControlStateHighlighted];
    [btn sizeToFit];
    self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc]initWithCustomView:btn];
//    监控按钮点击
    [btn addTarget:self action:@selector(back) forControlEvents:UIControlEventTouchUpInside];
   

    
// 注册cell
    [self.tableView registerNib:[UINib nibWithNibName:NSStringFromClass([XMGHotWBCell class]) bundle:nil] forCellReuseIdentifier:IM];
//   告诉tableView所有的cell的真实高度是自动计算的(根据设置约束)
    self.tableView.rowHeight = UITableViewAutomaticDimension;
//    告诉tableView所有的cell的估计高度
    self.tableView.estimatedRowHeight =44;
    
}

//监控返回按钮的箭头按钮
-(void)back
{

    [self.navigationController popViewControllerAnimated:YES];
}

#pragma mark-----------------------
#pragma mark---------UITableViewDataSouce

-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return 100;
}

-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    
//访问缓冲池
    XMGHotWBCell *cell = [tableView dequeueReusableCellWithIdentifier:IM];
  
    return cell;
}

//当tableView消失的时候让navigationBar显示
-(void)viewWillAppear:(BOOL)animated
{
    self.navigationController.navigationBar.hidden = NO;
}


@end
